
    function convert(num) {
        let nums = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
        let romans = ["M", "CM", "D", "Cd", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"];
        let str = '';
        nums.forEach(function (item, index, array) {
            while (num >= item) {
                str += romans[index];
                num -= item;
            }
        });

        return str;
    }

console.log(convert(36));
